# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=crackserver
pkgver=33.e5763ab
pkgrel=4
groups=('blackarch' 'blackarch-cracker')
pkgdesc='An XMLRPC server for password cracking.'
arch=('any')
url='https://github.com/averagesecurityguy/crack'
license=('custom')
depends=('python2' 'rcracki_mt' 'john' 'hashcat' 'ike-scan' 'pyrit')
makedepends=('git')
source=("$pkgname::git+https://github.com/averagesecurityguy/crack.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/" README.md

  rm README.md

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  _tools="crackserver crackclient"

  for tool in $_tools ; do
    cat > "$pkgdir/usr/bin/$tool" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $tool.py "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$tool"
  done

  cat > "$pkgdir/usr/bin/crack-standalone" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 crack.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/crack-standalone"
}

